package com.kitty.mina.filter;

import com.kitty.game.team.message.RespMsg;
import com.kitty.mina.message.Message;
import com.kitty.mina.message.MessageFactory;
import com.kitty.mina.message.MessagePusher;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.session.IoSession;
//后加
import com.kitty.mina.filter.NetGateKeeper;


public class ModuleEntranceFilter extends IoFilterAdapter {

    @Override
    public void messageReceived(NextFilter nextFilter, IoSession session, Object packet) throws Exception {
        Message message = (Message) packet;
        String messageId = MessageFactory.INSTANCE.getMessageId(message.getClass());

        if (NetGateKeeper.getInstance().canVisit(messageId)) {
            nextFilter.messageReceived(session, message);
        } else {
            // 模块功能出了bug，暂时把功能入口关闭了，等bug修复以后再重新打开
            MessagePusher.pushMessage(session, new RespMsg("This function is to be developed(Code:" + messageId + ")..."));
        }
    }

}
